﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Yu
{
    public class TargetImage : MonoBehaviour
    {
        int ID;
        RectTransform rect;
        Button button;
        public Image Image_Area;
        List<Item> Item = new List<Item>();

        // Use this for initialization
        void Start()
        {
            button = transform.GetComponentInChildren<Button>();
            rect = GetComponent<RectTransform>();
            ItemGroup.targetPoint.Add(this);
            ID = Globe.NowTargetCount++;
            button.onClick.AddListener(() =>
            {
                Destroy(gameObject);
            });
        }
        private void OnDestroy()
        {
            ItemGroup.targetPoint.Remove(this);
        }
       
        public void AddItem(Item item)
        {
            Item.Add(item);
        }

        public void RemoveItem(Item item)
        {
            Item.Remove(item);
        }

        // Update is called once per frame
        void Update()
        {

        }

        internal void SetImage(Sprite sprite)
        {
            Image_Area.sprite = sprite;
        }
    }
}
